package com.mhd.usercontroller.config;


import com.mhd.usercontroller.interceptor.AutoLogonInterceptor;
import com.mhd.usercontroller.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    LoginInterceptor loginInterceptor;

    @Autowired
    AutoLogonInterceptor autoLogonInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)  // 拦截器对象
                .addPathPatterns("/plateform.html");  // 要拦截的路径
//                .excludePathPatterns("/hello/abc");  // 要放行的路径
        registry.addInterceptor(autoLogonInterceptor)
                .addPathPatterns("/login.html");
    }
}
